<?php
/**
 * Created by PhpStorm.
 * User: lingyun
 * Date: 2018/3/19
 * Time: 20:44
 * Desc: 网站相关设置
 */
namespace app\admin\controller;
use controller\BasicAdmin;
use think\Db;
use app\admin\service\WebsiteService;

class Website extends BasicAdmin{
    /**
     * @Author  lingyun
     * @Desc    会员等级设置
     */
    public function member_level(){
        $this->title = '会员等级';
        $table = "SysLevel";
        $get = $this->request->get();
        $db = Db::name($table);

        return parent::_list($db);
    }

    /**
     * @Author  lingyun
     * @Desc    添加 -- 编辑会员等级
     */
    public function add_edit_level(){
        $request = request();
        $service = new WebsiteService();
        if($request->isPost()){
            $post = input('post.');
            $flag = $service->add_edit_level($post);
            $flag['code']!=0?$this->success("保存成功",''):$this->error($flag['msg'],'');
        }else{
            $id = input('id');
            $info = $service->get_member_level($id);

            $this->assign('title','会员等级');
            $this->assign('id',$id);

            return $this->fetch('add_edit_level');
        }
    }

    /**
     * @Author  lingyun
     * @Desc    删除会员等级
     */
    public function del_member_level(){
        $id = input('id');
        $service = new WebService();
        $flag = $service->del_member_level($id);
        $flag['code'] == 1?$this->success('删除成功',''):$this->error('删除失败','');
    }

}
